#include <iostream>
#include <cstring>
#define MAX(A,B) A>B?A:B
using namespace std;

int main(){
	int n;
	cin >> n;
	int table[101][101];
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= i; j++)
			cin >> table[i][j];
	int result[101][101];
	memset(result, 0, sizeof(result));
	result[1][1] = table[1][1];
	for(int i = 2; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(j == 1){
				result[i][j] = result[i - 1][j] + table[i][j];
				continue;
			}
			if(j == i){
				result[i][j] = result[i - 1][j - 1] + table[i][j];
				continue;
			}
			result[i][j] = MAX(result[i-1][j],result[i-1][j - 1]);
			result[i][j] += table[i][j];
		}
	}
	int max = 0;
	for(int i = 1; i <= n; i++){
		if(result[n][i] > max) max = result[n][i];
	}
	cout << max << endl;
}

